package com.zmn.oms.admin.controller.callpop;

import com.zmn.base.common.data.dubbo.interfaces.mobilecity.MobilecityListRemoteService;
import com.zmn.base.engineer.dubbo.interfaces.foreign.EngineerListRemoteService;
import com.zmn.consts.GlobalConsts;
import com.zmn.oms.business.interfaces.callpop.CallRecordBService;
import com.zmn.oms.common.constant.OrderStatusConsts;
import com.zmn.oms.model.entity.work.OrderWorkQuery;
import com.zmn.oms.model.vo.work.ZsOrderWorkVO;
import com.zmn.oms.zmn.business.interfaces.work.ZsOrderWorkQueryBService;
import org.apache.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 类描述：呼叫弹屏
 * @author lujia
 * @date 2019/02/18 17:28
 */
@Controller
@RequestMapping("/call")
public class CallPopOrderController {

    private static final Logger logger = LoggerFactory.getLogger(CallPopOrderController.class);

    /**
     * 114 中继号
     */
    private static final String DNIS_114 = "65934131,65934000,65934182,02365934182";

    @Reference(version = com.zmn.base.engineer.common.constants.DubboConsts.INTERFACE_VERSION, check = false)
    EngineerListRemoteService engineerListRemoteService;

    @Autowired
    ZsOrderWorkQueryBService zsOrderWorkQueryBService;

    @Autowired
    CallRecordBService callRecordBService;

    @Reference(version = com.zmn.base.plat.engine.common.constant.DubboConsts.INTERFACE_VERSION, check = false)
    MobilecityListRemoteService mobilecityListRemoteService;


    /**
     * 通过工程师id获取工单列表
     * @param masterId
     * @return
     */
    private List<ZsOrderWorkVO> getOrderWorkListByMasterId(Integer masterId) {
        OrderWorkQuery query = new OrderWorkQuery();
        query.setQueryWarning(GlobalConsts.YES);
        query.setMasterId(masterId);
        query.setWorkResultStatus(OrderStatusConsts.WORK_RESULT_DOING);
        query.setPageSize(100);
        List<ZsOrderWorkVO> orderWorkVOList = zsOrderWorkQueryBService.listPageOrderWorkByQuery(query);
        return orderWorkVOList;
    }

    /**
     * 通过用户手机号获取工单列表
     * @param phone
     * @return
     */
    private List<ZsOrderWorkVO> getOrderWorkListByUser(String phone, String startTime, String endTime) {
        OrderWorkQuery query = new OrderWorkQuery();
        query.setQueryWarning(GlobalConsts.YES);
        query.setConcatPhone(phone);
        query.setPageSize(100);
        query.setReceiveTime(startTime + "," + endTime);
        List<ZsOrderWorkVO> orderWorkVOList = zsOrderWorkQueryBService.listPageOrderWorkByQuery(query);
        return orderWorkVOList;
    }

    // /**
    //  * 获取投诉列表
    //  * @param phone
    //  * @param startTime
    //  * @param endTime
    //  * @return
    //  */
    // private List<CallComplaintVO> getComplaintList(String phone, String startTime, String endTime) {
    //     TrackCustomerDIO trackCustomerDIO = new TrackCustomerDIO();
    //     trackCustomerDIO.setPhone(phone);
    //     trackCustomerDIO.setStartTime(startTime);
    //     trackCustomerDIO.setEndTime(endTime);
    //     ResponseDTO<List<TrackBaseComplainDRO>> responseDTO = complainListRemoteService
    //             .listTrackComplainByCustomer(trackCustomerDIO);
    //     if (responseDTO.isSuccess() && responseDTO.getData() != null) {
    //         List<TrackBaseComplainDRO> items = responseDTO.getData();
    //         List<CallComplaintVO> callComplaintList = BeanMapper.mapList(items, CallComplaintVO.class);
    //         callComplaintList.forEach(e -> {
    //             Integer timeoutPeriod = e.getTimeoutPeriod();
    //             if (timeoutPeriod != null && timeoutPeriod > 0) {
    //                 e.setTimeOutStr(DateUtil.secondToTime(timeoutPeriod));
    //             }
    //         });
    //         return callComplaintList;
    //     }
	//
    //     return Lists.newArrayList();
    // }

}
